package com.endava.Generics;

import java.util.ArrayList;
import java.util.List;

/*
 * 1. Write a generic method to count the number of elements in a collection 
 * that have a specific property (for example, odd integers, prime numbers, palindromes).
 */
public class Ex1 {

	public static void main(String[] args) {

		List<Integer> list = new ArrayList<Integer>();
		list.add(0);
		list.add(1);
		list.add(2);
		list.add(3);
		list.add(4);
		list.add(5);
		list.add(6);
		list.add(7);
		list.add(8);
		list.add(9);

		
		Ex1 a = new Ex1();
		Ex1.number(list);

		// selectMyPrimeNumbers();

	}

	public static <T extends Number> void number(List<Integer> list) {
		int count = 0;
		for (Integer number : list) {
			if (number.intValue() % 2 == 1) {
				count++;
			}
		}
		System.out.println("nr of prime numbers " + count);
	}

}
